<template>
  <div>
    <Header_h />
    <div class="sq_box_content">
      <bannerInfo :info="info" />
    </div>
    <div class="new_box_bgcolor">
      <div class="new_box">
        <div class="container">
          <div class="s_flex s_align_items_start">
            <div style="width: 100%">
              <section class="core_content_left core_content">
                <div class="finance_item">
                  <div
                    v-for="(item, index) in list.list"
                    :key="index"
                    class="
                      item_list
                      s_flex s_flex_comlou s_justify_content_between
                    "
                    @click="goNews(item.id)"
                    @mouseenter="enter(index)"
                    @mouseleave="leave(index)"
                    :class="check == index ? 'li_active' : ''"
                  >
                    <div class="item_list_img">
                      <div class="img_wap">
                        <img class="item_list_img" :src="item.tpic" alt />
                      </div>
                    </div>
                    <div class="right_info">
                      <!-- <p class="sq_content sq_content_color">
                      {{ news.online_time }}
                    </p>-->
                      <h3
                        class="
                          sq_title3
                          line_h_30
                          sq_tilte_color
                          content_spacing
                          ft_weight_800
                        "
                      >
                        {{ item.title }}
                      </h3>
                      <div class="sq_content sq_content_color">
                        <p
                          class="ft_weight_400 line_h_26 words-hidden-2"
                          v-html="item.content"
                        ></p>
                      </div>
                      <div
                        class="sq_sign_btn sq_content sq_sign_btn3"
                        @click="examine(item.id)"
                      >
                        立即查看
                      </div>
                    </div>
                  </div>
                  <!-- <div
                  v-for="(item, index) in listTwo.list"
                  :key="index"
                  class="item_list s_flex s_flex_comlou s_justify_content_between"
                  @click="goNews(item.id)"
                  @mouseenter="enter(index)"
                  @mouseleave="leave(index)"
                  :class="check == index ? 'li_active' : ''"
                >
                  <div class="item_list_img">
                    <div class="img_wap">
                      <img class="item_list_img" :src="item.tpic" alt />
                    </div>
                  </div>
                  <div class="right_info">
                    <h3
                      class="sq_title3 line_h_30 sq_tilte_color content_spacing ft_weight_800"
                    >{{ item.title }}</h3>
                    <div class="sq_content sq_content_color">
                      <p class="ft_weight_400 line_h_26 words-hidden-2" v-html="item.content"></p>
                    </div>
                    <div
                      class="sq_sign_btn sq_content sq_sign_btn3"
                      @click.stop="getUrl(item, 6)"
                    >立即查看</div>
                  </div>
                </div> -->
                </div>
              </section>
            </div>
          </div>
          <div class="pagination">
            <el-pagination
              background
              small
              @current-change="handleCurrentChange"
              :current-page="list.page"
              :page-size="list.size"
              layout="total, prev, pager, next, jumper"
              :total="parseInt(list.count)"
              align="left"
              :pager-count="5"
            ></el-pagination>
          </div>
        </div>
      </div>
    </div>
    <Footer />
    <rightMenu @moveTo="moveTo" />

    <signUp
      :dialogVisible="dialogVisible"
      @handleClose="handleClose"
      @submit="submit"
      :type="type"
      :text="text"
    />
  </div>
</template>

<script>
import Header_h from "@/components/Header_h";
import Footer from "@/components/Footer";
import bannerInfo from "@/components/web/bannerInfo";
import { knowledgelist, consultAdd, storyinnovatelist } from "@/api/web";
import signUp from "@/components/web/signUp";
import rightMenu from "@/components/web/rightMenu";
import { PAGE_BASE_URL } from "@/config";

export default {
  components: {
    Header_h,
    Footer,
    bannerInfo,
    signUp,
    rightMenu,
  },
  data() {
    return {
      info: {
        title: "顺德创新故事",
        // content: "顺德创新企业优秀故事",
        content: "顺德创新故事",
        img: require("@/assets/web/banner1.png"),
      },
      list: [],
      // listOne: [],
      // listTwo: [],
      banner: [],
      check: -1,
      dialogVisible: false,
      url: "",
      text: {
        title: "咨询",
        btn: "提交",
      },
      type: 7,
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    //点击第几页
    async handleCurrentChange(currentPage) {
      try {
        this.getList(currentPage);
      } catch (e) {
        this.$message.error(e.message);
      }
    },
    moveTo() {
      window.scrollTo(0, 0);
    },
    async getList(page = 1) {
      try {
        // this.listOne = await knowledgelist({ type: 1 });
        // this.listTwo = await knowledgelist({ type: 2 });
        this.list = await storyinnovatelist({ page, page_size: 10 });
      } catch (error) {
        this.$message.error(error.message);
      }
    },
    examine(id) {
      this.$router.push({ path: "/web/dialogue", query: { id: id } });
    },
    goNews(id) {
      // this.$router.push({ path: "/web/facturing/details", query: { id: id } });
      this.$router.push({ path: "/web/dialogue", query: { id: id } });
    },
    webUrl(url) {
      window.open(url);
    },
    enter(index) {
      this.check = index;
    },
    leave() {
      this.check = -1;
    },
    checkItem(index) {
      this.active = index;
    },
    async handleClose() {
      this.dialogVisible = false;
    },
    async submit(form) {
      try {
        await consultAdd({ ...form, from: this.url });
        this.$message.success("提交成功");
      } catch (error) {
        this.$message.error(error.message);
      }
      this.dialogVisible = false;
    },
    getUrl(item, index) {
      // 点击专利保险
      this.type = index;
      this.text = {
        title:
          "请填写您的联系方式，我们工作人员将尽快与您联系，将为您提供”" +
          item.title +
          "“相关咨询服务。",
        btn: "提交",
      };
      if (item.file) {
        this.url = item.file;
      } else {
        this.url = `${PAGE_BASE_URL}/#/web/facturing/details?id=${item.id}`;
      }
      this.dialogVisible = true;
    },
  },
};
</script>

<style lang="less" scoped>
.pagination {
  width: 90%;
  margin: auto 0;
}
.new_box {
  margin-top: -4%;
  position: relative;
  z-index: 1;
  margin-bottom: 25px;
}
.core_content .item_list_img {
  width: 240px;
  object-fit: cover;
  overflow: hidden;
  .img_wap {
    padding-bottom: 56%;
    width: 100%;
    position: relative;
    img {
      width: 100%;
      transition: all 0.5s ease;
      &:hover {
        transform: scale(1.1);
      }
    }
  }
}

.li_active {
  width: 100%;
  background: #ffffff;
  box-shadow: 0 0 16px rgba(24, 76, 171, 0.16);
  border: none;
}

.right_info {
  width: 75%;
  // margin-left: 25px;
}

.core_content .item_list {
  border-bottom: 1px solid #eee;
  padding: 23px 15px;
  width: 100%;
  margin: 30px auto 0;
  background: #ffffff;
  border: 1px solid #ced4ea;
  cursor: pointer;
  transition: all 0.2s ease;
}

// .core_content .item_list:last-child {
//   margin-bottom: 0;
// }

.content_spacing {
  // margin:0 auto 10px;
}
.core_content_left {
  width: 100%;
  background-color: #fff;
  height: 100%;
}
.core_content_right {
  width: 25%;
  background-color: #fff;
}
.content_right_spacing {
  margin: 10px 0;
}
.list_right {
  border-top: 1px solid #eee;
  padding: 10px 0;
  margin: 0 10px;
}
.right_title {
  margin: 0 10px;
  padding: 10px 0;
}

.finance_item {
  padding: 30px;
  background: #ffffff;
  box-shadow: 0 0 16px rgba(24, 76, 171, 0.16);
  margin-bottom: 25px;
  p {
    margin-top: 10px;
  }
  .sq_sign_btn {
    margin-top: 10px;
  }
}

@media (max-width: 750px) {
  .core_content {
    padding: 0 !important;
  }
  .finance_item:last-child {
    margin-bottom: 0;
  }
  .right_info {
    width: 100%;
  }
  .finance_item .sq_sign_btn {
    margin-top: 10px;
    margin: 20px auto 0;
  }
  .right_info h3 {
    margin-top: 10px;
  }
  .finance_item {
    padding: 30px 15px;
  }
  .core_content .item_list_img {
    width: 100%;
  }
}
</style>